/*----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the 
License at http://www.mozilla.org/MPL/
	
Software distributed under the License is distributed on 
an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 
either express or implied. 
See the License for the specific language governing rights and 
limitations under the License.
	
The Original Code is Fever RS ( ActionScript 3 ) Framework code.
	
The Initial Developer of the Original Code is Romain Ecarnot.
Portions created by Initial Developer are Copyright (C) 2006
the Initial Developer. All Rights Reserved.
	
Contributor(s):
	
Unless required by applicable law or agreed to in writing, 
software distributed under the License is distributed on 
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
OF ANY KIND, either express or implied.
See the License for the specific language governing permissions 
and limitations under the License.
----------------------------------------------------------------------------*/

package fever.events 
{
	import com.bourre.events.BasicEvent;
	
	import fever.ui.menu.PopupContextMenu;
	import fever.ui.menu.PopupContextMenuItem;	

	/**
	 * The ContextMenuEvent class represents the event object passed to 
	 * the event listener when a user generates or interacts with 
	 * a <strong>context menu</strong>.
	 * 
	 * <p>Users generate the context menu by clicking the secondary button 
	 * of the user's pointing device (usually a mouse or a trackball).<br />
	 * There are two types of ContextMenuEvent objects:
	 * <ul>
	 * 	<li><code>PopupContextMenuEvent.onContextMenuSelectEVENT</code>
	 * 	<li><code>PopupContextMenuEvent.onContextItemSelectEVENT</code>
	 * </ul>
	 * </p>
	 * 
	 * @see fever.ui.menu.PopupContextMenu	 * @see fever.ui.menu.PopupContextMenuItem	 * @see fever.ui.menu.PopupContextMenuLocator
	 * 
	 * @author Romain Ecarnot
	 */
	final public class PopupContextMenuEvent extends BasicEvent
	{
		//--------------------------------------------------------------------
		// Events
		//--------------------------------------------------------------------
		
		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onContextMenuSelect</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>getContextMenu()</code></td>
	     *     	<td><code>PopupContextMenu object</code></td>
	     *     </tr>
	     *  </table>
	     *  
		 * @eventType onContextMenuSelect
		 */
		public static const onContextMenuSelectEVENT : String = "onContextMenuSelect";
		
		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onContextItemSelect</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>getContextMenu()</code></td>
	     *     	<td><code>PopupContextMenu object</code></td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>getContextItem()</code></td>
	     *     	<td><code>PopupContextMenuItem object</code></td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onContextItemSelect
		 * 
		 * @see fever.ui.menu.PopupContextMenu
	     * @see fever.ui.menu.PopupContextMenuItem
		 */		public static const onContextItemSelectEVENT : String = "onContextItemSelect";
		
		
		//--------------------------------------------------------------------
		// Private properties
		//--------------------------------------------------------------------
		
		private var _menu : PopupContextMenu;
		private var _item : PopupContextMenuItem;
		

		//--------------------------------------------------------------------
		// Public API
		//--------------------------------------------------------------------
		
		/**
		 * Constructor.
		 * 
		 * @param type Event type
		 * @param menu PopupContextMenu target		 * @param item PopupContextMenuItem target
		 */
		public function PopupContextMenuEvent( type : String, 
			menu : PopupContextMenu, item : PopupContextMenuItem = null)
		{
			super( type );
			
			_menu = menu;
			_item = item;
		}
		
		/**
		 * Returns targeted PopupContextMenu instance.
		 */
		public function getContextMenu() : PopupContextMenu
		{
			return _menu;
		}
		
		/**
		 * Returns targeted PopupContextMenuItem instance if 
		 * exist.
		 */
		public function getContextItem() : PopupContextMenuItem
		{
			return _item;
		}
	}
}
